<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>其实应该每个都加标题的</title>
</head>

<body>
    <title>移除不想要的数组，新生成自然数排列的数组newArry</title>

    <script>
        var arr = [1, 2, 3, 4, 2, 5, 6, 2, 7, 2];
        var newArr = [];
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] != 2) {
                newArr[newArr.length] = arr[i];
            }
        }
        console.log(newArr);
    </script>
</body>

</html>